<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
	<link rel="stylesheet" href="../../layui/css/layui.css">
</head>
<body>
    <form class="layui-form" action="" style="margin-left:70px;">
		<div class="layui-fluid">
			<div class="layui-card-body">
				<div class="layui-form" lay-filter="">
					<div class="layui-form-item">
						<label class="layui-form-label">控件类型</label>
						<div class="layui-input-inline" style="width:160px">
							<select id="Modeltype" name="Modeltype" lay-filter="Modeltype">
								<option value="1">深度</option>
								<option value="2">时间</option>
							</select>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">曲线名称</label>
						<div class="layui-input-block" style="width:160px">
							<select id="ident" name="ident" class="from-control" lay-filter="ident"></select>
						</div>
					</div>

					<div id="non" style="display: none;">
						<input type="text" id="hd1" hidden value="">
						<input type="text" id="hd2" hidden value="">
					</div>
					
					<div id="pubval">
						<div class="layui-form" lay-filter="">
							<div class="layui-form-item">
								<label class="layui-form-label">最大值</label>
								<div class="layui-input-inline">
									<input type="text" id="Cmax" name="Cmax" value="" autocomplete="off" class="layui-input" style="width:160px">
								</div>
							</div>
						</div>
						<div class="layui-form" lay-filter="">
							<div class="layui-form-item">
								<label class="layui-form-label">最小值</label>
								<div class="layui-input-inline">
									<input type="text" id="Cmin" name="Cmin" value="" autocomplete="off" class="layui-input" style="width:160px">
								</div>
							</div>
						</div>
						
					</div>	
					
				</div>
			</div>
		</div>

	</form>
</body>
<script type="text/javascript" src="../../layui/layui.js"></script>
<script type="text/javascript" src="../../jquery-3.0.0.min.js"></script>
<script type="text/javascript" src="../../layui/public.js"></script>
<script>
      layui.use(['form', 'colorpicker', 'layer'], function () {
        var form = layui.form;
        var colorpicker = layui.colorpicker;
		var layer = layui.layer;
		var list;
		console.log(123)
		//身份验证
		// var getoken = GetToken(dataobj);
		if(getoken!=false){
			//获取单位
			$.ajax({
            type: "get",
            url: api_address + '/curve/getcur',
            async: false,
            headers: {
                Authorization: getoken
            },
            contentType: 'application/json;',
            success: function (res) {
                if (res.code == 200) {
					list=res.data;
					for (let i = 0; i < list.length; i++) {
						if(list[i].curveType==4){
							var ze="<option value='0'>请选择</option>";
							$("select[name=ident]").append(ze);
							var option = "<option value=\"" + list[i].curveName + "\"";
                                option += ">" + list[i].curveName + "</option>"; //动态添加数据
								$("select[name=ident]").append(option);
						}
						
					}
					form.render();
					
                }

            }
		 });

		     //曲线类型监听事件
		form.on('select(Modeltype)', function (data) {
            $("#ident").empty();
            for (var i = 0; i < list.length; i++) {
                if (data.value == list[i].curveType) {
                  var option = "<option value=\"" + list[i].curveName + "\"";
                  option += ">" + list[i].curveName + "</option>"; //动态添加数据
                  $("select[name=ident]").append(option);
                }
            }
            form.render();
        })
		
		    //曲线名称的监听事件
			form.on('select(ident)', function (data) {
                var vs = $("#ident option:checked").val();
                for (var i = 0; i < list.length; i++) {
                    if (vs == list[i].curveName) {
                        $("#Cmax").val(list[i].cmax);
                        $("#Cmin").val(list[i].cmin);
						$("#hd1").val(list[i].tableName)
                        $("#hd2").val(list[i].params)   
                    }
                }
            })
		}
	  })
	  var retdata=function(){
		var type =  $("#Modeltype option:checked").val(); //标识
		var Name =  $("#ident option:checked").text(); //标识
		let max= $("#Cmax").val();
		let min= $("#Cmin").val();
		let tablename=$("#hd1").val();
		let parameter= $("#hd2").val();
		var data=  {type,Name,max,min,tablename,parameter};
		return data;
	  }
</script>
</html>